import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		str: 123,
		forcedLogin: true,
		hasLogin: false,
		userName: "",
		tabindex: 0,
		userID:'',
		proID:'',
		reportValue:''
	},
	mutations: {
		login(state, data) {
			state.userName = data.data.username;
			state.userID = data.data.id
			state.hasLogin = true;
			uni.setStorageSync('user', state.userName);
			uni.setStorageSync('userID', state.userID);
			uni.setStorageSync('hasLogin', state.hasLogin);
			uni.setStorageSync('factoryId', data.data.factoryId);
		},
		logout(state) {
			state.userName = "";
			state.hasLogin = false;
			uni.removeStorageSync('user')
			uni.removeStorageSync('hasLogin')
			uni.removeStorageSync('factoryId')
		},
		increment (state, n) {
		   state.reportValue = n;
		   console.log(n)
		   console.log(state.reportValue)
		}

	}
})

export default store
